package File;

import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class PathInfo {

    static void show(String id, Object object) {
        System.out.println(id + " : " + object);
    }


    static void info(Path path) {
        show("toString", path);
        show("exists", Files.exists(path));
        show("regular", Files.isRegularFile(path));
        show("directory", Files.isDirectory(path));
        show("absolute", path.isAbsolute());
        show("filenaem", path.getFileName());
        show("parent", path.getParent());
        show("root", path.getRoot());
    }

    public static void main(String[] args) {


        System.out.println(System.getProperty("os.name"));
        info(Paths.get("C:\\Users\\Administrator\\Desktop\\lanqiaobei"));
        Path path = Paths.get("src/main/java/File/PathInfo.java");
        System.out.println("----------");
        info(path);

        Path path1 = path.toAbsolutePath();
        System.out.println("_---------");
        info(path1);

        URI uri = path1.toUri();
        System.out.println("uri:" + uri);
        System.out.println("sd-f----d---");
        info(Paths.get(uri));

        for (int i = 0; i < path.getNameCount(); i++) {
            System.out.println(path.getName(i));

        }

        System.out.println("-----start end");
        System.out.println(path);
        System.out.println(path.endsWith("PathInfo.java"));
        System.out.println(path.startsWith("src"));
    }
}
